home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kjs / function.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  2.2 KB  |  66 lines

  1. // -*- c-basic-offset: 2 -*-
  2. /*
  3.  *  This file is part of the KDE libraries
  4.  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
  5.  *  Copyright (C) 2003 Apple Computer, Inc.
  6.  *
  7.  *  This library is free software; you can redistribute it and/or
  8.  *  modify it under the terms of the GNU Library General Public
  9.  *  License as published by the Free Software Foundation; either
  10.  *  version 2 of the License, or (at your option) any later version.
  11.  *
  12.  *  This library is distributed in the hope that it will be useful,
  13.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  *  Library General Public License for more details.
  16.  *
  17.  *  You should have received a copy of the GNU Library General Public License
  18.  *  along with this library; see the file COPYING.LIB.  If not, write to
  19.  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20.  *  Boston, MA 02110-1301, USA.
  21.  *
  22.  */
  23.  
  24. #ifndef _KJS_FUNCTION_H_
  25. #define _KJS_FUNCTION_H_
  26.  
  27. #include "object.h"
  28.  
  29. namespace KJS {
  30.  
  31.   class FunctionPrototypeImp;
  32.  
  33.   /**
  34.    * Base class for all function objects.
  35.    * It implements the hasInstance method (for instanceof, which only applies to function objects)
  36.    * and allows to give the function a name, used in toString().
  37.    *
  38.    * Constructors and prototypes of internal objects (implemented in C++) directly inherit from this.
  39.    * FunctionImp also does, for functions implemented in JS.
  40.    */
  41.   class KJS_EXPORT InternalFunctionImp : public ObjectImp {
  42.   public:
  43.     /**
  44.      * Constructor. For C++-implemented functions, @p funcProto is usually
  45.      * static_cast<FunctionPrototypeImp*>(exec->interpreter()->builtinFunctionPrototype().imp())
  46.      */
  47.     InternalFunctionImp(FunctionPrototypeImp *funcProto);
  48.     InternalFunctionImp(ExecState *exec);
  49.  
  50.     bool implementsHasInstance() const;
  51.     Boolean hasInstance(ExecState *exec, const Value &value);
  52.  
  53.     virtual const ClassInfo *classInfo() const { return &info; }
  54.     static const ClassInfo info;
  55.     Identifier name() const { return ident; }
  56.     /// You might want to use the helper function ObjectImp::setFunctionName for this
  57.     void setName(Identifier _ident) { ident = _ident; }
  58.  
  59.   protected:
  60.     Identifier ident;
  61.   };
  62.  
  63. } // namespace
  64.  
  65. #endif
  66.